return
-def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
+def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1,sock=None):
from xen.xend import XendDomain
try:
if checkpoint:
dominfo.resumeDomain()
else:
+ if live and sock != None:
+ try:
+ sock.shutdown(2)
+ except:
+ pass
+ sock.close()
+
dominfo.destroy()
dominfo.testDeviceComplete()
try:
try:
try:
XendCheckpoint.save(p2cwrite, dominfo, True, live, dst,
- node=node)
+ node=node,sock=sock)
except Exception, ex:
m_dsterr = None
try:
raise XendError("%s (from %s)" % (m_dsterr.group(2), dst))
raise
finally:
- try:
- sock.shutdown(2)
- except:
- # Probably the socket is already disconnected by sock.close
- # in the destination side.
- # Ignore the exception because it has nothing to do with
- # an exception of XendCheckpoint.save.
- pass
- sock.close()
+ if not live:
+ try:
+ sock.shutdown(2)
+ except:
+ # Probably the socket is already disconnected by sock.close
+ # in the destination side.
+ # Ignore the exception because it has nothing to do with
+ # an exception of XendCheckpoint.save.
+ pass
+ sock.close()
os.close(p2cread)
os.close(p2cwrite)
try:
try:
XendCheckpoint.save(sock.fileno(), dominfo, True, live,
- dst, node=node)
+ dst, node=node,sock=sock)
except Exception, ex:
m_dsterr = None
try:
raise XendError("%s (from %s)" % (m_dsterr.group(2), dst))
raise
finally:
- try:
- sock.shutdown(2)
- except:
- # Probably the socket is already disconnected by sock.close
- # in the destination side.
- # Ignore the exception because it has nothing to do with
- # an exception of XendCheckpoint.save.
- pass
- sock.close()
+ if not live:
+ try:
+ sock.shutdown(2)
+ except:
+ # Probably the socket is already disconnected by sock.close
+ # in the destination side.
+ # Ignore the exception because it has nothing to do with
+ # an exception of XendCheckpoint.save.
+ pass
+ sock.close()
def domain_save(self, domid, dst, checkpoint=False):
"""Start saving a domain to file.